﻿<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="com.hatic.store.DocumentHandler,java.io.File,java.io.FileInputStream,java.io.OutputStream,java.net.URLEncoder" %>
<%
		String[] keyids = request.getParameterValues("keyid");

		String downPath = application.getRealPath("")+"\\project\\store\\download\\projectinfo.doc";
		DocumentHandler dh = new DocumentHandler();
		File file = dh.createDoc(downPath,keyids);
		
        response.setContentType("application/octet-stream");
        String fileName = "项目库存信息.doc";
        response.addHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName,"UTF-8"));
        
        FileInputStream in;
		try {
			in = new FileInputStream(file);
			OutputStream output = response.getOutputStream();
	        byte[] b = new byte[1024];
	        int i = in.read(b);  
	        while (i != -1) {  
	            output.write(b,0,i); 
	            i = in.read(b);
	        }
	        output.flush();
	        in.close();
	        output.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
%>